from pydantic import BaseModel
from typing import Optional, List
from datetime import date, datetime

# 用户统计基础模式
class UserStatsBase(BaseModel):
    user_id: int
    stat_date: date
    tts_count: int = 0
    asr_seconds: int = 0

# 创建用户统计模式
class UserStatsCreate(UserStatsBase):
    pass

# 更新用户统计模式
class UserStatsUpdate(BaseModel):
    tts_count: Optional[int] = None
    asr_seconds: Optional[int] = None

# 用户统计输出模式
class UserStatsOut(BaseModel):
    id: int
    user_id: int
    stat_date: date
    tts_count: int
    asr_seconds: int

    class Config:
        from_attributes = True

# 用户统计响应模式（用于API返回）
class UserStatsResponse(BaseModel):
    date: str
    tts_count: int
    asr_seconds: int

# TTS统计请求模式
class TTSStatsRequest(BaseModel):
    user_id: int
    text_length: int
    date: Optional[str] = None

# ASR统计请求模式
class ASRStatsRequest(BaseModel):
    user_id: int
    seconds: int
    date: Optional[str] = None

# 用户统计查询模式
class UserStatsQuery(BaseModel):
    user_id: int
    start_date: Optional[date] = None
    end_date: Optional[date] = None 